<!-- redirect.html -->
{% load static %}

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="refresh" content="3; url={{ redirect_url }}" />
    <link rel="icon" type="image/x-icon" href="{% static 'favicon.ico' %}">
    <title>跳转中...</title>
    <script>
      var seconds = 3; // 倒计时时间
      document.addEventListener("DOMContentLoaded", function () {
        var display = document.querySelector("#timeLeft");
        var redirectUrl = "{{ redirect_url }}"; // 使用 Django 模板标签
        setInterval(function () {
          display.textContent = seconds + " 秒后跳转...";
          seconds -= 1;
          if (seconds < 0) {
            window.location.href = redirectUrl; // 使用变量而不是硬编码的 URL
          }
        }, 1000);
      });
    </script>
  </head>
  <body>
    <p>{{ message }}</p>
    <p>请稍候，</p>
    <p id="timeLeft"></p>
    <p>我们将自动为您跳转。</p>
  </body>
</html>
